package com.zhangmeng.online.exam.entity;

import com.zhangmeng.online.exam.entity.baseEntity.BaseEntity;
import lombok.*;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 试卷
 * @author zm
 * @date 2025/3/18 16:21
 * @version: 1.0
 */
@NoArgsConstructor
@ToString(exclude = {"questions","creator"})
@Getter
@Setter
@AllArgsConstructor
@Entity
@Table(name = "paper")
public class Paper extends BaseEntity<Long> {

    private String name;//试卷名称

    private String description;//试卷描述

    private Integer totalScore;//总分

    private Integer passScore;//及格分数

    private Integer examTime;//考试时间

    private Integer type;//答案

    private Integer status;//试卷状态

    @ManyToOne(targetEntity = Subject.class,fetch = FetchType.LAZY)
    private Subject subject;//所属科目

    @ManyToOne(targetEntity = User.class,fetch = FetchType.LAZY)
    private User creator;//创建人

    @ManyToMany(targetEntity = Question.class)
    @JoinTable(name = "paper_question", joinColumns = @JoinColumn(name = "paper_id"), inverseJoinColumns = @JoinColumn(name = "question_id"))
    private List<Question> questions = new ArrayList<Question>();//试卷题目列表

}
